import { api } from 'src/boot/axios'

// 添加请求拦截器
api.interceptors.request.use(config => {
  const token = localStorage.getItem('token')
  if (token) {
    config.headers.Authorization = token
  }
  return config
})

export const authApi = {
  login(code) {
    return api.get('/api/auth/login', {
      params: { code }
    })
  },
  
  loginRedirect() {
    return api.post('/api/auth/login')
  },

  logout() {
    return api.post('/api/auth/logout')
  },

  checkToken() {
    return api.get('/api/auth/check-token')
  }
}